<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="icon" href="">
    <link href="https://static.9hive.cn/global/vendor/bootstrap-3.3.7/bootstrap.min.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/nprogress/nprogress.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/fonts/font-awesome/font-awesome.min.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/icheck/icheck.min.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/animate/animate.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/bootstrap-table-1.11/bootstrap-table.min.css?v=1.1" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/common/common_20170925.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/inside/inside.css?v=1" rel="stylesheet">

</head>

<body class="white-bg">
<div class="wrapper wrapper-content ibox float-e-margins">
    <div class="ibox-title">
        <div class="pull-left mbx">
            品牌账号<span class="line">/</span>
            <span class="current">角色管理</span>
        </div>
    </div>
    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="col-sm-12" >
                    <div class="alert alert-warning alert-dismissable">
                        <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                        可以对角列表进行管理，并进行增删改查。
                    </div>
                    <div class="btn-group hidden-xs" id="eventsToolbar" role="group">
                        <button type="button" class="btn btn-outline btn-default"  id="add">
                            <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>添加
                        </button>
                    </div>
                    <table id="cpTableEvents" data-toggle="table" data-mobile-responsive="true" class="table table-bordered table-strip table-hovered">
                        <thead>
                        <tr>
                            <th data-field="name">角色名称</th>
                            <th data-field="modifyDate">修改日期</th>
                            <th data-field="head" data-formatter="opFormatter" data-halign="center"  data-align="center">操作</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>


</div>
<script src="https://static.9hive.cn/global/vendor/jquery/jquery-2.1.4.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/nprogress/nprogress.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-3.3.7/bootstrap.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-validate/jquery.validate.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-validate/additional-methods.min.js"></script>

<script src="https://static.9hive.cn/global/vendor/jquery-validate/localization/messages_zh.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-ajaxform/ajax-form.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-table-1.11/bootstrap-table.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-table-1.11/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/layer/layer.js"></script>

<script>

    function opFormatter(value, row, index){
        var html = '<a href="javascript:void(0)" onclick="edit(\''+row.id+'\');" class="fa fa-pencil" data-toggle="tooltip" title="编辑" style="font-size: 15px"></a>';
        html += '<a href="javascript:void(0)" onclick="openWindow(\''+row.id+'\',\''+row.name+'\');"><span style="margin-left:10px;font-size: 15px" class="fa fa fa-reorder" data-toggle="tooltip" title="资源管理"></span></a>';
        html += '<a href="javascript:void(0)" onclick="del(\''+row.id+'\');"><span style="margin-left:10px;font-size: 15px" class="fa fa-trash-o" data-toggle="tooltip" title="删除"></span></a>';
        return html;
    }

    function nameFormatter(value, row, index) {
        if(row.valuenames){
            return value + "<span style='color: #00a0e9;margin-left: 5px'>["+row.valuenames+"]</span>";
        }else
            return value;
    }

    function boolFormatter(v) {
        if(v)
            return '是';
        else
            return '否';
    }

    function typeFormatter(v) {
        if(v == 0)
            return '文本';
        else if(v == 1)
            return '数字';
        else if(v == 2)
            return '字母';
        else if(v == 3)
            return '单选项';
        else if(v == 4)
            return '多选项';
        else if(v == 5)
            return '日期';
    }

    function del(v) {
        $.post('delete',{"ids":v},function (e) {
            if(e.state == "fail"){
                layer.msg(e.info);
            }else{
                layer.msg("删除成功!");
                $('#cpTableEvents').bootstrapTable('refresh');
            }
        });
    }


    function edit(v) {
        location.href = "edit?id="+v;
    }
    function openWindow(id,name) {
        parent.layer.open({
            type: 2,
            title: name+'的角色资源配置',
            //shadeClose: true,
            //shade: 0.8,
            shade: [0.3,'#fff'],//0.1透明度的白色背景
            area: ['380px', '60%'],
            content: '${base}/shop/role/resource?roleId='+id //iframe的url
        });
    }

    (function() {
        $('#cpTableEvents').bootstrapTable({
            url: "${base}/shop/role/ajaxlist",
            search: true,
            pagination: true,
            showRefresh: true,
            showToggle: true,
            showColumns: true,
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            icons: {
                refresh: 'glyphicon-repeat',
                toggle: 'glyphicon-list-alt',
                columns: 'glyphicon-list'
            }
        });
        $(".wrapper").tooltip({selector:"[data-toggle=tooltip]",container:"body"});

        $('#eventsToolbar').on('click',function (e) {
            location.href = 'add';
        });

    })();
</script>
</body>

</html>
